Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-cdk/aws-codebuild

Package Overview
Dependencies
Maintainers
4
Versions
288
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-cdk/aws-codebuild

CDK Constructs for AWS CodeBuild

  • 0.15.2
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

AWS CodeBuild Construct Library

Define a project. This will also create an IAM Role and IAM Policy for CodeBuild to use.

Using CodeBuild with other AWS services

CodeCommit

Create a CodeBuild project with CodeCommit as the source:

import codebuild = require('@aws-cdk/aws-codebuild');
import codecommit = require('@aws-cdk/aws-codecommit');

const repo = new codecommit.Repository(this, 'MyRepo', { repositoryName: 'foo' });
new codebuild.Project(this, 'MyFirstCodeCommitProject', {
    source: new codebuild.CodeCommitSource(repo)
});
S3

Create a CodeBuild project with an S3 bucket as the source:

import codebuild = require('@aws-cdk/aws-codebuild');
import s3 = require('@aws-cdk/aws-s3');

const bucket = new s3.Bucket(this, 'MyBucket');
new codebuild.Project(this, 'MyProject', {
    source: new codebuild.S3BucketSource(bucket, 'path/to/source.zip')
});
CodePipeline

Example of a Project used in CodePipeline, alongside CodeCommit:

import codebuild = require('@aws-cdk/aws-codebuild');
import codecommit = require('@aws-cdk/aws-codecommit');
import codepipeline = require('@aws-cdk/aws-codepipeline');

const repository = new codecommit.Repository(this, 'MyRepository', {
    repositoryName: 'MyRepository',
});

const project = new codebuild.PipelineProject(this, 'MyProject');

const pipeline = new codepipeline.Pipeline(this, 'MyPipeline');

const sourceStage = pipeline.addStage('Source');
repository.addToPipeline(sourceStage, 'CodeCommit');

const buildStage = pipeline.addStage('Build');
new codebuild.PipelineBuildAction(this, 'CodeBuild', {
    stage: buildStage,
    project,
});

The PipelineProject utility class is a simple sugar around the Project class, it's equivalent to:

const project = new codebuild.Project(this, 'MyProject', {
    source: new codebuild.CodePipelineSource(),
    artifacts: new codebuild.CodePipelineBuildArtifacts(),
    // rest of the properties from PipelineProject are passed unchanged...
}

You can also add the Project to the Pipeline directly:

// equivalent to the code above:
const buildAction = project.addBuildToPipeline(buildStage, 'CodeBuild');

In addition to the build Action, there is also a test Action. It works very similarly to the build Action, the only difference is that the test Action does not always produce an output artifact.

Examples:

new codebuild.PipelineTestAction(this, 'IntegrationTest', {
    stage: buildStage,
    project,
    // outputArtifactName is optional - if you don't specify it,
    // the Action will have an undefined `outputArtifact` property
    outputArtifactName: 'IntegrationTestOutput',
});

// equivalent to the code above:
project.addTestToPipeline(buildStage, 'IntegrationTest', {
    // of course, this property is optional here as well
    outputArtifactName: 'IntegrationTestOutput',
});

Using Project as an event target

The Project construct implements the IEventRuleTarget interface. This means that it can be used as a target for event rules:

// start build when a commit is pushed
codeCommitRepository.onCommit('OnCommit', project);

Using Project as an event source

To define CloudWatch event rules for build projects, use one of the onXxx methods:

const rule = project.onStateChange('BuildStateChange');
rule.addTarget(lambdaFunction);

Keywords

FAQs

Package last updated on 08 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc